<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cz.acies.data.*"%>
<%@ page import="cz.acies.data.dao.*"%>
<%@ page import="cz.acies.data.persist.*"%>
<%@ page import="cz.acies.face.*"%>

<%@ page import="com.google.gson.Gson"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String jqxPath = path + "/libs/kendoui";

//System.out.println("jqxPath: " + jqxPath); 

String title = application.getServletContextName();
String theme = "";
//theme = "bootstrap";
//theme = "default";
//theme = "flat";
theme = "metro";
//theme = "metro-blue";

//BasePage basePage = new BasePage();
//String jsFiles = basePage.getJsInit(jqxPath);
UserContext userContext = new UserContext();
userContext.setWorkerId("WX.R.AEFBE4JE41ZYBEM");
userContext.db(DBConnector.instance());
session.setAttribute("userContext", userContext);

session.setAttribute("ApplicationTheme", theme);

Gson gson = new Gson();

DesktopDAO uiDao = new DesktopDAO();
List<TreeNode> list = uiDao.getDesktopMenuData();
String treeNode = gson.toJson(list);
%>
<!DOCTYPE HTML>
<html>
<head>
<title><%=title%></title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8" />

<link href="<%=path%>/libs/themes/<%=theme%>/easyui.css" rel="stylesheet" type="text/css">
<link href="<%=path%>/libs/themes/icon.css" rel="stylesheet" type="text/css">

<style type="text/css">
html, body {
	width: 100%;
	height: 100%;
	margin: 0px;
	padding: 0px;
	overflow: hidden;
	font-size: 11px;
	font-family: sans-serif, Helvetica, Verdana;
}
.icon-contact { background:url("/organizer/res/icons/contacts_24.png") no-repeat center center; }
.icon-calendar { background:url("/organizer/res/icons/calendar_16.png") no-repeat center center; }
.icon-email { background:url("/organizer/res/icons/email_16.png") no-repeat center center; }
.icon-repository { background:url("/organizer/res/icons/user_repository_16.png") no-repeat center center; }
.icon-banking { background:url("/organizer/res/icons/banking_16.png") no-repeat center center; }
.icon-users { background:url("/organizer/res/icons/users_16.png") no-repeat center center; }
</style>

<script type="text/javascript" src="<%=path%>/libs/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<%=path%>/libs/aciea.utils.js"></script>
<script type="text/javascript" src="<%=path%>/libs/jquery.easyui.min.js"></script>

<script>
var treeData = <%=treeNode%>; 

$(document.body).ready(function() {
	$("#menuPanel").tree({
		data: treeData,
		onSelect: function(node){
			if (node.attributes.selectable) {
 				var label = "" + node.text;
 				var image = "" + node.iconCls;
				if ($("#modulTabs").tabs("exists", label)) {
					$("#modulTabs").tabs("select", label);
				} else {
					var params = { processId: "getModulPageContent", modulId: ""+node.attributes.modulId, menuId: ""+node.id };
					var url = "<%=path%>/pages/default_modul_process.jsp";
					var content = executeAjaxSync(url, params);
					$("#modulTabs").tabs("add",{
						title: ""+label,
						iconCls: ""+image,
						content: ""+content,
						fit: true,
						closable: true
					});
					var tab = $("#modulTabs").tabs("getSelected");
					tab.css({ "overflow": "hidden" });
				}
			}
		}
	});
	$("#modulTabs").tabs({fit : true});
});
</script>
</head>

<body class="easyui-layout">
	<div id="topPanel" data-options="region:'north',border:true" style="height:30px; background-color:rgb(44,105,167);">
		<div style='padding:5px;font-size: 16px;color: white'>Acies Organizer 2013</div>
	</div>
	<div id="menuPanel" data-options="region:'west',border:false" style="width:200px;">
		<ul id="menuTree" class="easyui-tree"></ul>
	</div>
	<div id="modulPanel" data-options="region:'center',border:true">
		<div id="modulTabs" class="easyui-tabs">
			<div id="tab_LX.M.PREVIEW" title="+" style="padding:10px;overflow:hidden;"></div>
		</div>
	</div>
</body>
</html>
